/**
 * @file 公共title
 * @author wl
 * @date 20200311
 */
import React from 'react';
import {Card, Button, Divider, Tooltip} from 'antd';

import './index.less';


const Title = props => {
    const {
        title,
        iconDom,
        timeLabel = '数据更新至：',
        time,
        remark,
        containerStyle,
        mainStyle,
        subStyle,
        // mainTitle 主标题、 subTitle 副标题
        type = 'mainTitle',
    } = props;

    return (
        type === 'mainTitle' ? (
            // id 用于锚点
            <div style={{...containerStyle}} className="main-title" id={`anchor${title}`}>
                {title && (
                    <span style={{...mainStyle}} className="title">
                        {title}
                    </span>
                )}
                {iconDom && (
                    <span className="time">
                        {iconDom}
                    </span>
                )}
                {time && (
                    <span className="time">
                        {timeLabel + time}
                    </span>
                )}
                {remark && (
                    <span className="remark">
                        {remark}
                    </span>
                )}
            </div>
        ) : (
            <div style={{...containerStyle}} className="sub-title" id={`anchor${title}`}>
                {title && (
                    <span style={{...subStyle}} className="title">
                        {title}
                    </span>
                )}
                {iconDom && (
                    <span className="time">
                        {iconDom}
                    </span>
                )}
                {time && (
                    <span className="time">
                        {timeLabel + time}
                    </span>
                )}
                {remark && (
                    <span className="remark">
                        {remark}
                    </span>
                )}
            </div>
        )
    );
};

export default Title;
